const express = require('express')
//创建http服务器
const app = express()
//引入path内置模块
const path = require('path')

//获取全盘路径
const rootPath = path.join(__dirname,'../public')
//1、静态资源服务器
app.use(express.static(rootPath))

//中间件格式化请求体的参数，
app.use(
    express.json(),
    express.urlencoded()
)

//2、接口服务器，RESTful规范
//引入<根>路由模块
const rootRouter = require('./router')
app.use('/api',rootRouter)



//监听端口
app.listen(3000,()=>{
    console.log('server is running at port 3000!!')
})